/**
 * 后台日志管理路由
 */
const express = require('express');

// 用户中间件
const user = require('../../middleware/user');
// 日志中间件
const log = require('../../middleware/log');
// 后台日志管理路由
const logApp = express();
// (new Date().toLocaleDateString)
// 日志列表页
logApp.get('/',[log.getCount],(req,res,next)=>{
    let page = {
        p:req.query.p ? req.query.p :1,
        count:req.count,
        size:6,
    }
    page.total = Math.ceil(page.count/page.size);
    page.p = page.p > page.total ? page.total : page.p;
    page.p = page.p < 1 ? 1: page.p;

    req.page = page;
    next();
},[user.lastLoginTime,log.getPageLog],(req,res)=>{
    let {user,logs,page} = req;
    res.render('admin/log/index',{user,logs,page})
});

module.exports = logApp;